package cn.chinaunicom.mini.program.dingtalk.config;

import cn.chinaunicom.mini.program.dingtalk.events.publisher.DingTalkPublisher;
import cn.chinaunicom.mini.program.dingtalk.events.stream.DingTalkEventStreamConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.PostConstruct;

/**
 * @ProjectName: dingtalk-property
 * @Package: cn.chinaunicom.property.config
 * @ClassName: DingTalkConfig
 * @Description: 钉钉订阅事件配置
 * @Author: wangjc
 * @CreateDate: 2024/6/5
 * @UpdateUser: wangjc
 * @UpdateDate: 2024/6/5
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
@Slf4j
//@Configuration
public class DingTalkConfig {

    @Value("${dingtalk.clientId}")
    private String clientId;

    @Value("${dingtalk.clientSecret}")
    private String clientSecret;

    @Autowired
    private DingTalkPublisher publisher;

    @PostConstruct
    public void buildEventPublisher() throws Exception {
        DingTalkEventStreamConfig.builder().clientId(clientId).clientSecret(clientSecret).publisher(publisher).build().start();
        log.info("[DingTalk Config] buildEventPublisher success！！！");
    }
}
